﻿using System;
using System.IO;
using System.Collections;
namespace test
{
    class Program
    {
        public class FileComparer : IComparer
        {
            int IComparer.Compare(Object o1, Object o2)
            {
                FileSystemInfo fi1 = o1 as FileSystemInfo;
                FileSystemInfo fi2 = o2 as FileSystemInfo;
                return fi1.CreationTime.CompareTo(fi2.CreationTime);
            }
        }

        public class MyClass
        {
            public FileInfo[] GetFiles(string path)
            {
                DirectoryInfo di = new DirectoryInfo(path);
                FileInfo[] files = di.GetFiles();
                FileComparer fc = new FileComparer();
                Array.Sort(files, fc);
                int i = 1;
                foreach (FileInfo fileh in files)
                {
                   
                    string s = i + fileh.Name;
                    
                    fileh.MoveTo(Path.Combine(path, s));
                    i++;
                }
                Console.Read();
                return  files;
               
            
                
                
            }
        }

        static void Main(string[] args)
        {

            FileSystemInfo[] a = new MyClass().GetFiles(@"H:\资料");
            //DirectoryInfo dicInfo = new DirectoryInfo(@"H:\123");
            ////            
            // FileSystemInfo[] textFiles = dicInfo.GetFileSystemInfos();
            //   foreach (FileSystemInfo fileInfo in textFiles)
            //   {
            //       Console.WriteLine(fileInfo.FullName+"\n"+fileInfo.CreationTime);//文件其它信息同
                 
            //   }
            //   Console.Read();
        }

    }
}